<%--
  User: zs
  Date: 2017/6/30
  Time: 16:12
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table id="mytab">
    <form action="upload.action" method="post" enctype="multipart/form-data">
        <font color="#8b0000"><s:fielderror/></font>
        <tr>
            <td>
                选择文件：<input type="file" name="upload"/><br>
                <%--选择文件2：<input type="file" name="upload"/><br>--%>
            </td>
        </tr>

        <tr>
            <td>
                <input value="上传" type="submit"/>
                <input type="button" value="添加一个文件" id="btn">
            </td>
        </tr>
    </form>
</table>

</body>
</html>
<script src="js/jquery-1.8.3.js" language="JavaScript"></script>
<script>
    $(function () {
        $("#btn").live("click",function () {
            var mytab = document.getElementById("mytab");
            var newRow=mytab.insertRow(mytab.rows.length-1); //创建行
            //live
            //为新建的行和列添加内容
            newRow.insertCell(0).innerHTML="选择文件：<input type='file' name='upload'/>";
        });

    })


    /*function insertRow() {
        var mytab = document.getElementById("mytab");
        var newRow=mytab.insertRow(mytab.rows.length-1); //创建行
        //live
        //为新建的行和列添加内容
        newRow.insertCell(0).innerHTML="选择文件：<input type='file' name='upload'/>";
    }*/
</script>
